<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    

    <script>
        window.onkeydown=function(){
            //event 事件源(按键)
            if(event.keyCode=="13"){
                alert("登录成功!"); //按enter键
            }
        }



        window.onkeyup=function(){
            if(event.keyCode=="65"){
                alert("登录成功!"); //按住小写的a
            } 
            //按住按键不松手是不会触发的 当松手时 按键回弹则触发
        }
    </script>
</body>
</html>